using AutoMapper;
using Pay.DTO;
using Pay.Data;
using Pay.IService;

namespace Pay.Service.AutoMapper
{
    public class NoticeMapper : IStartupDto
    {
        private IMapperConfigurationExpression _cfg;
        public NoticeMapper(IMapperConfigurationExpression cfg)
        {
            _cfg = cfg;
        }
        public void Execute()
        {
            Create();
        }
        protected virtual void Create()
        {
            _cfg.CreateMap<Notice, notice_dto>()
                .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.title, src => src.MapFrom(c => c.Title))
                .ForMember(dest => dest.type, src => src.MapFrom(c => c.Type))
                .ForMember(dest => dest.url, src => src.MapFrom(c => c.Url))
                .ForMember(dest => dest.content, src => src.MapFrom(c => c.Content))
                .ForMember(dest => dest.create_time, src => src.MapFrom(c => c.CreateTime))
                .ForMember(dest => dest.status, src => src.MapFrom(c => c.Status))
                .ForMember(dest => dest.click_num, src => src.MapFrom(c => c.ClickNum))
                .ForMember(dest => dest.release_time, src => src.MapFrom(c => c.ReleaseTime));


            _cfg.CreateMap<notice_dto, Notice>()
                .ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
                .ForMember(dest => dest.Title, src => src.MapFrom(c => c.title))
                .ForMember(dest => dest.Type, src => src.MapFrom(c => c.type))
                .ForMember(dest => dest.Url, src => src.MapFrom(c => c.url))
                .ForMember(dest => dest.Content, src => src.MapFrom(c => c.content))
                .ForMember(dest => dest.CreateTime, src => src.MapFrom(c => c.create_time))
                .ForMember(dest => dest.Status, src => src.MapFrom(c => c.status))
                .ForMember(dest => dest.ClickNum, src => src.MapFrom(c => c.click_num))
                .ForMember(dest => dest.ReleaseTime, src => src.MapFrom(c => c.release_time)); 


        }
    }
}
